<template>
	<view class="work-container">
		<!-- 搜索框-->
		<uni-search-bar @confirm="handleQuery" v-model="queryParams.pigCode" placeholder="请输入耳号" bgColor="#ffffff">
		</uni-search-bar>
		<uni-group mode="card" v-for="(item, index) in pigBreedList" :index="index" :key="index">
			<view class="code">
				<text style="font-size:18px">母猪耳号：{{item.pigCode}}</text>
				<uni-icons class="icon" type="right" size="15" color="#000000"
					@click="toDetials(item.pigBreedId)"></uni-icons>
			</view>
			<hr />
			<view class="message">
				<view v-if="item.pigBreedType == 1"> 配种方式：{{$dict.selectDictLabel('hmy_pig_breed_type', 1)}} </view>
				<view v-else-if="item.pigBreedType ==2"> 配种方式：{{$dict.selectDictLabel('hmy_pig_breed_type', 2)}} </view>
				<view> 公猪耳号：{{item.pigFatherCode}}</view>
				<view> 配种管理员：{{item.hmyStaff.staffName}}</view>
				<view> 配种日期：{{item.pigBreedTime}}</view>
			</view>
		</uni-group>
		<!-- 加载更多 -->
		<uni-load-more iconType="auto" :status="status" />
		<!-- 新增加号悬浮 icon -->
		<uni-fab :pattern="pattern" :horizontal="horizontal" :vertical="vertical" @fabClick="fabClick" />
	</view>
</template>

<script>
	import {
		listPigBreed,
		getPigBreed,
		delPigBreed,
		addPigBreed,
		updatePigBreed
	} from "@/api/hmy/pigBreed";
	export default {
		name: "PigBreed",

		data() {
			return {
				// 猪只配种记录数据
				pigBreedList: [],
				horizontal: 'right',
				vertical: 'bottom',
				pattern: {
					buttonColor: '#55aa7f',
				},
				//加载更多
				status: 'more',
				total: '',
				// 查询参数
				queryParams: {
					pageNum: 1,
					pageSize: 10,
					type: undefined,
				}
			};
		},
		created() {
			this.getList();
		},
		//上拉加载
		onReachBottom() {
			this.queryParams.pageSize += 5;
			this.getList();
			if (this.pigBreedList.length >= this.total) {
				this.status = 'noMore';
			} else {
				this.status = 'loading';
			}
		},
		methods: {
			/** 查询猪只配种列表 */
			/** 查询进货列表 */
			getList() {
				uni.showLoading({
					title:"加载中"
				})
				listPigBreed(this.queryParams).then(response => {
					//console.log(response)
					this.pigBreedList = response.rows;
					this.total = response.total;
					uni.hideLoading();
				});
			},
			// 新增配种记录
			fabClick() {
				this.$tab.navigateTo('/pages/hmy/pigBreed/pigBreedAdd');
			},
			/** 搜索按钮操作 */
			handleQuery() {
				this.queryParams.pageNum = 1;
				this.getList();
			},

			//详情
			toDetials(e) {
				console.log("xiangqing", e)
				this.$tab.navigateTo('/pages/hmy/pigBreed/pigBreedDetials?id=' + e);
			}
		}
	};
</script>

<style lang="scss">
	/* #ifndef APP-NVUE */
	page {
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
		min-height: 100%;
		height: auto;
		background-color: #fcfcfc;
	}

	view {
		font-size: 16px;
		line-height: inherit;
	}

	/* #endif */
	.code {
		margin-bottom: 5px;
	}

	.icon {
		float: right;
		margin-right: 10px;
		margin-top: 5px;
	}

	.message {
		margin-top: 5px;
		color: #989897;
		line-height: 25px;
	}
</style>